﻿using Common;
using DataLibrary;
using System;
using System.Linq;
using System.Windows.Forms;

namespace TicketSystem
{
    public partial class Form_TravelTypeUpdate : Form
    {
        public Form_TravelTypeUpdate()
        {
            InitializeComponent();
        }
        public string typename;
        private TicketSystemEntities tse = new TicketSystemEntities();
        private void Form_TravelTypeUpdate_Load(object sender, EventArgs e)
        {
            var departmenttype = tse.DepartmentTypes.Where(u => u.TypeName == typename).FirstOrDefault();
            this.txtTypeName.Text = departmenttype.TypeName;
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            var departmenttype = tse.DepartmentTypes.Where(u => u.TypeName == typename).FirstOrDefault();
            departmenttype.TypeName = this.txtTypeName.Text;
            tse.Configuration.ValidateOnSaveEnabled = false;
            tse.SaveChanges();
            MessageBox.Show("修改成功");
            this.Close();
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}
